package seed_commerce

import (
	"fmt"
	"gitee.com/theegg/go-brick/app/model/commerce/merchants"
	"github.com/xormplus/xorm"
)

func InitMerchantSeed(db *xorm.Engine) {
	items := make(map[int]merchants.Merchants)
	items[1] = merchants.Merchants{
		MerchantName: "淘宝小店",
		PartnerSign:  "SHJJ",
		Sign:         "MC10000001",
		Summary:      "淘宝小店自2008年开办以来,未卖出一单",
		Avatar:       "",
		AddTime:      1,
		AddIp:        "127.0.0.1",
		AddAdminId:   1,
	}

	items[2] = merchants.Merchants{
		MerchantName: "动力(1)店",
		PartnerSign:  "WPDL",
		Sign:         "MC10000002",
		Summary:      "动力(2)店, 成衣，童装的购物不二选择",
		Avatar:       "",
		AddTime:      1,
		AddIp:        "127.0.0.1",
		AddAdminId:   1,
	}

	items[3] = merchants.Merchants{
		MerchantName: "动力(2)店",
		PartnerSign:  "WPDL",
		Sign:         "MC10000003",
		Summary:      "动力(2)店, 专注高端鞋子仿制",
		Avatar:       "",
		AddTime:      1,
		AddIp:        "127.0.0.1",
		AddAdminId:   1,
	}

	count := 0
	errCount := 0
	for _, item := range items {
		_, err := db.Insert(item)
		if err != nil {
			fmt.Println(err.Error())
			errCount++
		} else {
			count++
		}
	}

	fmt.Printf("%5s|%25s|%10d|%8d|\n", "", "merchants", count, errCount)
}
